
import 'package:flutter/material.dart';
import 'package:flutterlib/common/style/quhui_style.dart';
import 'package:flutterlib/widgets/pull/nested/simple_pull_load_manger.dart';
import 'package:flutterlib/widgets/pull/nested/simple_pull_load_page_widget.dart';

abstract class BaseSliverListNoAppbar extends StatefulWidget {

  BaseSliverListNoAppbar({Key key})
      : super(key: key);

  @override
  BaseSliverListNoAppbarState createState();
}

///页面 KeepAlive ，同时支持 动画Ticker
abstract class BaseSliverListNoAppbarState<T extends BaseSliverListNoAppbar> extends State<T>
    with TickerProviderStateMixin {
  SimplePullLoadManger manger;

  ///滑动监听
  final ScrollController scrollController = new ScrollController();

  getDataLogic(int page);

  Widget renderItem(index, activity);

  ///绘制内置Header，支持部分停靠支持
  List<Widget> renderHeader(BuildContext context, bool innerBoxIsScrolled);

  bool enablePullUp();

  bool enablePullDown();

  @override
  void initState() {
    super.initState();
    manger = SimplePullLoadManger.needSliverHeader(
        getDataLogic: getDataLogic,
        renderItem: renderItem,
        renderHeader: renderHeader,
        enablePullUp: enablePullUp(),
        enablePullDown: enablePullDown()
    );
  }

  @override
  Widget build(BuildContext context) {
    return SimplePullLoadWidget(
      pullLoadManger: manger,
    );
  }
}
